﻿/// <summary>
/// https://leetcode-cn.com/problems/jump-game/
/// </summary>
public class Solution
{
    public bool CanJump(int[] nums)
    {
        int last = 0;
        int next = 0;
        for (int i = 0; i < nums.Length - 1; i++)
        {
            next = Math.Max(next, nums[i] + i);
            if (i == last)
                last = next;
            if (i >= last)
                return false;
        }
        return true;
    }
}